﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true"
    CodeBehind="JT_TheaterAdd.aspx.cs" Inherits="JTicket.UI.JT_TheaterAdd" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        //页面初始下载
        $(document).ready(
    function () {
        $.ajax({
            type: "GET",
            url: "RoleTypeHandle.axd?Time=" + new Date(),
            success: function (Result) {
                if (Result != "-1") {
                    var arr = eval(Result.toString());
                    if (arr.length > 0) {
                        for (var i = 0; i < arr.length; i++) {
                            $("#seCompany").append("<option value=" +
                     arr[i].CodeVal + ">" + arr[i].CodeNote + "</option>");
                        }
                    } 
                }
            },
            fail: function () { isAlertError(); }
        });

        if (Flag == "Edite") {
            $("#BtnAdd").hide();
            JTicket.UI.Service.JT_ThSvc.GetModel(ID,
        function Success(Reuslt) {
            if (Reuslt != null) {


                $("[name='S1']").val(Reuslt.GroupRole);
                $("#txtadress").val(Reuslt.ThAddress);
                $("#txtcity").val(Reuslt.ThCity);
                $("#txtThCode").val(Reuslt.ThCode);
                $("#txtcontant").val(Reuslt.ThContact);
                $("#txtcoy").val(Reuslt.ThCopy);
                $("#txtinfo").val(Reuslt.ThInfo);
                $("#txtlogo").val(Reuslt.ThLogo);
                $("#txtmobeil").val(Reuslt.ThMobeil);
                $("#txtThName").val(Reuslt.ThName);
                $("#txtprov").val(Reuslt.ThProvince);
                $("#txtremake").val(Reuslt.ThRemak);
                $("#txtThCode").attr("disabled", "disabled");
                if (Reuslt.ThState == "0") {
                    $("[name='chState']").check = false;
                } else { $("[name='chState']").check = true; }



                $("#txttaxname").val(Reuslt.ThTaxName);
                $("#txttaxno").val(Reuslt.ThTaxNum);
                $("#txttel").val(Reuslt.ThTel);
                $("#txtvison").val(Reuslt.ThVersion);
            } else {
                window.location.href = "JT_TheaterManager.aspx";
            }
        },
         function Fail(Reuslt) { alert(Reuslt.get_message()); });
        } else {

            $("#BtnEdite").hide();
        }
    });
        //添加
        function Add() {

            if ($("[name='S1']").attr("value") == "0") {
                alert('请选择用户组角色');
                return;
            }

            var model = new JTicket.Model.C_TheaterInfo(); 
            model.CompayCode = "无";
            model.CompayName = "无";
            model.GroupRole = $("[name='S1']").attr("value");
            model.GroupRoleName = $("#seCompany").find("option:selected").text();
            model.ThAddress = $("#txtadress").attr("value");
            model.ThCity = $("#txtcity").attr("value");
            model.ThCode = $("#txtThCode").attr("value");
            model.ThContact = $("#txtcontant").attr("value");
            model.ThCopy = $("#txtcoy").attr("value");
            model.ThInfo = $("#txtinfo").attr("value");
            model.ThLogo = $("#txtlogo").attr("value");
            model.ThMobeil = $("#txtmobeil").attr("value");
            model.ThName = $("#txtThName").attr("value");
            model.ThProvince = $("#txtprov").attr("value");
            model.ThRemak = $("#txtremake").attr("value");
            model.ThTaxName = $("#txttaxname").attr("value");
            model.ThTaxNum = $("#txttaxno").attr("value");
            model.ThTel = $("#txttel").attr("value");
            model.ThVersion = $("#txtvison").attr("value");
            model.ThState = 0;
            if ($("[name='chState']").check) {
                model.ThState = 1;
            } 
            JTicket.UI.Service.JT_ThSvc.Add(model,
            function Success(Result) {
                if (Result == "添加成功！") {
                    window.location.href = "JT_TheaterManager.aspx";
                } else {
                    alert(Result);
                }
            },
            function fail(Result) { isAlertError(); });
        }
        //修改
        function Update() {
            if ($("#seCompany").find("option:selected").val() == "0") {
                alert('请选择用户组角色');
                return;
            }
            var model = new JTicket.Model.C_TheaterInfo();
            model.CompayCode = "无";
            model.CompayName = "无";
            model.GroupRole = $("#seCompany").find("option:selected").val();
            model.GroupRoleName = $("#seCompany").find("option:selected").text();
            model.ThAddress = $("#txtadress").attr("value");
            model.ThCity = $("#txtcity").attr("value");
            model.ThCode = $("#txtThCode").attr("value");
            model.ThContact = $("#txtcontant").attr("value");
            model.ThCopy = $("#txtcoy").attr("value");
            model.ThInfo = $("#txtinfo").attr("value");
            model.ThLogo = $("#txtlogo").attr("value");
            model.ThMobeil = $("#txtmobeil").attr("value");
            model.ThName = $("#txtThName").attr("value");
            model.ThProvince = $("#txtprov").attr("value");
            model.ThRemak = $("#txtremake").attr("value");
            model.ThTaxName = $("#txttaxname").attr("value");
            model.ThTaxNum = $("#txttaxno").attr("value");
            model.ThTel = $("#txttel").attr("value");
            model.ThVersion = $("#txtvison").attr("value");
            model.ThState = 0; 
            $("#txtThCode").attr("disabled", "disabled");
            $("#BtnEdite").attr("disabled", "disabled");
            if ($("[name='chState']").check) {
                model.ThState = 1;
            }
            JTicket.UI.Service.JT_ThSvc.Update(model,
            function Success(Result) {
                alert(Result);
                window.location.href = "JT_TheaterManager.aspx";

            },
            function fail() {
                alert("修改失败,请重新操作！");
                $("#BtnEdite").removeAttr("disabled");
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager ID="sm" runat="server">
        <Services>
            <asp:ServiceReference InlineScript="true" Path="~/Service/JT_ThSvc.asmx" />
        </Services>
    </asp:ScriptManager>
    <table align="center" border="0" cellpadding="4" cellspacing="1" class="toptable grid"
        width="100%">
        <tr>
            <td class="category t2" height="25" width="100">
                剧院添加
            </td>
            <td class="category" height="25">
            </td>
        </tr>
    </table>
    <table cellpadding="1" cellspacing="1" id="TbInfo" class="TbInfo">
        <tr>
            <td align="right" bgcolor="#3890B5" class="B" style="width: 130px">
                名称
            </td>
            <td height="25" align="right" bgcolor="#3890B5" class="B">
                操作
            </td>
            <td align="right" bgcolor="#3890B5" class="B" style="width: 50px">
                说明
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px; height: 25px;">
                用户组角色：
            </td>
            <td align="left" bgcolor="#F6F6F6" style="height: 25px">
                <select id="seCompany" name="S1">
                    <option value="0">-请选择用户组角色-</option>

                </select>
            </td>
            <td bgcolor="#F6F6F6" style="height: 25px; width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px; height: 25px;">
                &nbsp;编&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 号：
            </td>
            <td align="left" bgcolor="#F6F6F6" style="height: 25px">
                <input id="txtThCode" type="text" />
            </td>
            <td bgcolor="#F6F6F6" style="height: 25px; width: 171px;">
                必填
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px; height: 25px;">
                名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 称：
            </td>
            <td align="left" bgcolor="#F6F6F6" style="height: 25px">
                <input id="txtThName" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="height: 25px; width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px; height: 25px;">
                地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 址：
            </td>
            <td align="left" bgcolor="#F6F6F6" style="height: 25px">
                <input id="txtadress" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="height: 25px; width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px; height: 25px;">
                电&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 话：
            </td>
            <td align="left" bgcolor="#F6F6F6" style="height: 25px">
                <input id="txttel" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="height: 25px; width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px; height: 25px;">
                联&nbsp;&nbsp; 系&nbsp;&nbsp; 人：
            </td>
            <td align="left" bgcolor="#F6F6F6" style="height: 25px">
                <input id="txtcontant" type="text" />
            </td>
            <td bgcolor="#F6F6F6" style="height: 25px; width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                联系人电话：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txtmobeil" type="text" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                所住&nbsp;&nbsp; 省份：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txtprov" type="text" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                所在&nbsp;&nbsp; 城市：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txtcity" type="text" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                版&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 权：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txtcoy" type="text" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                系统标题：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txtvison" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                LOGO：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txtlogo" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                税 务 号：&nbsp;&nbsp;
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txttaxno" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                税务名称：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <input id="txttaxname" type="text" style="width: 300px;" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                简介：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <textarea id="txtinfo" class="textarea" cols="20" name="S2" rows="2"></textarea>
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px;">
                备注：
            </td>
            <td bgcolor="#F6F6F6" style="width: 130px;">
                <textarea id="txtremake" class="textarea" cols="20" name="S1" rows="2"></textarea>
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#f6f6f6" style="height: 27px; width: 130px;">
                启用状态：
            </td>
            <td align="left" bgcolor="#f6f6f6" style="height: 27px; width: 130px;">
                <input id="chState" value="启用" checked="checked" type="checkbox" class="checkbox" />
                启用
            </td>
            <td bgcolor="#f6f6f6" style="height: 27px; width: 171px;">
                &nbsp;
            </td>
        </tr>
        <tr>
            <td align="center" bgcolor="#F6F6F6" style="width: 130px">
            </td>
            <td height="25" bgcolor="#F6F6F6" align="center">
                <input type="button" id="BtnAdd" value="添  加" onclick="Add();" onmousemove="showBtnOver(this)"
                    onmouseout="showBtnOut(this)" class="submitMiniGreen" />
                <input type="button" id="BtnEdite" value="修  改" onclick="Update();" onmousemove="showBtnOver(this)"
                    onmouseout="showBtnOut(this)" class="submitMiniGreen" />
                <input type="button" id="BtnBack" value="返  回" onclick="javascript:window.location.href ='JT_TheaterManager.aspx'"
                    onmousemove="showBtnOver(this)" onmouseout="showBtnOut(this)" class="submitMiniGreen" />
            </td>
            <td bgcolor="#F6F6F6" style="width: 171px">
                &nbsp;
            </td>
        </tr>
    </table>
</asp:Content>
